import axios from 'axios'
import store from '@/store'
// import { Message } from 'element-ui'
const request = axios.create({
  // 开发环境使用：'/api'
  // 生产环境使用 '/prop-api'
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000 }
)
request.interceptors.request.use(config => {
  const token = store.state.user.token
  if (token) {
    config.headers.Authorization = token
  }
  return config
}, error => Promise.reject(error)
)
request.interceptors.response.use(response => {
  // if (response.data.msg === 'OK') { return response.data } else {
  //   // Message.error(response.data.msg)
  //   return Promise.reject(response.data.msg)
  // }
  return response
}, error => Promise.reject(error)
)
export default request
